﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    //Lop ket noi CSDL

    //DataConnection connection = new DataConnection();

    //string SELECT_ALL = "SELECT * from SanPham";


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
    }
    public DataSet list_pro_pager_dal()
    {
        string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        using (SqlConnection conn = new SqlConnection(strConn))
        {
            string Sql = "SELECT * from SanPham";
            SqlCommand cmd = new SqlCommand("SELECT * from SanPham", conn);
            //cmd.Parameters.AddWithValue("@masp");
            SqlDataAdapter adt = new SqlDataAdapter(Sql, conn);
            DataSet ds = new DataSet();
            adt.Fill(ds);
            return ds;
        }
    }


    void BindData()
    {
        CollectionPager1.PageSize = 4;
        CollectionPager1.DataSource = list_pro_pager_dal().Tables[0].DefaultView;
        CollectionPager1.BindToControl = DataList1;
        DataList1.DataSource = CollectionPager1.DataSourcePaged;
        DataList1.DataBind();
    }

}
